﻿using SqlSugar;
using TiaoTiaoCode.BasicDbCore;

namespace TiaoTiaoCode.AutoUpdate.DbCore.Entities
{
    /// <summary>
    /// 程序文件表
    /// </summary>
    [SugarTable("program_file_detail", TableDescription = "程序文件表")]
    public class ProgramFileDetail : BaseEntity
    {
        /// <summary>
        /// SqlSugar 需要无参构造
        /// </summary>
        public ProgramFileDetail()
        {
            MainProgramVersionId = string.Empty;
            FileName = string.Empty;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mainProgramVersionId"></param>
        /// <param name="fileName"></param>
        public ProgramFileDetail(string mainProgramVersionId, string fileName) => (MainProgramVersionId, FileName) = (mainProgramVersionId, fileName);

        /// <summary>
        /// MainProgram表主键Id
        /// </summary>
        [SugarColumn(ColumnName = "main_program_version_id", Length = 64, ColumnDescription = "MainProgram表主键Id")]
        public string MainProgramVersionId { get; set; }

        /// <summary>
        /// 文件名
        /// </summary>
        [SugarColumn(ColumnName = "file_name", Length = 200, ColumnDescription = "文件名")]
        public string FileName { get; set; }

        /// <summary>
        /// 文件所有相对主程序的子目录
        /// 默认为空，即在根目录
        /// </summary>
        [SugarColumn(ColumnName = "catalog", Length = 1000, IsNullable = true, ColumnDescription = "文件所有相对主程序的子目录\r\n默认为空，即在根目录")]
        public string? Catalog { get; set; }

        /// <summary>
        /// 主版本号
        /// </summary>
        [SugarColumn(ColumnName = "major", ColumnDescription = "主版本号")]
        public int Major { get; set; }

        /// <summary>
        /// 子版本号
        /// </summary>
        [SugarColumn(ColumnName = "version", ColumnDescription = "子版本号")]
        public int Version { get; set; }

        /// <summary>
        /// 修正版本号
        /// </summary>
        [SugarColumn(ColumnName = "minor_number", ColumnDescription = "修正版本号")]
        public int MinorNumber { get; set; }

        /// <summary>
        /// 编译版本号
        /// </summary>
        [SugarColumn(ColumnName = "build_number", ColumnDescription = "编译版本号")]
        public int BuildNumber { get; set; }

        /// <summary>
        /// 用户自定义说明版本号
        /// </summary>
        [SugarColumn(ColumnName = "custom_version", Length = 100, IsNullable = true, ColumnDescription = "用户自定义说明版本号")]
        public string? CustomVersion { get; set; }

        /// <summary>
        /// 文件是否需要更新
        /// </summary>
        [SugarColumn(ColumnName = "is_need_update", ColumnDescription = "文件是否需要更新")]
        public bool IsNeedUpdate { get; set; }

        /// <summary>
        /// 映射主表对象
        /// </summary>
        [Navigate(NavigateType.OneToOne, nameof(MainProgramVersionId))]
        public MainProgramVersion? MainProgram { get; set; }
    }
}
